package org.uned.agonzalo16.bitacora.dao;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Service;
import org.uned.agonzalo16.bitacora.domain.Article;
import org.uned.agonzalo16.bitacora.domain.Blog;
import org.uned.agonzalo16.bitacora.domain.BlogContribution;
import org.uned.agonzalo16.bitacora.domain.Comment;
import org.uned.agonzalo16.bitacora.domain.Message;
import org.uned.agonzalo16.bitacora.domain.User;

import com.googlecode.objectify.Objectify;
import com.googlecode.objectify.ObjectifyFactory;
import com.googlecode.objectify.ObjectifyService;

@Service
public class OfyFactory implements InitializingBean {

	@Override
	public void afterPropertiesSet() throws Exception {
		factory().register(Blog.class);
		factory().register(Article.class);
		factory().register(Comment.class);
		factory().register(User.class);
		factory().register(Message.class);
		factory().register(BlogContribution.class);
	}

	public static Objectify ofy() {
		return ObjectifyService.ofy();
	}

	public static ObjectifyFactory factory() {
		return ObjectifyService.factory();
	}

}
